home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / Extension Shell 1.3 / Sample Extensions / Quadra INIT ƒ / QuadraGestalt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-06  |  2.9 KB  |  111 lines  |  [TEXT/R*ch]

  1. /*    NAME:
  2.         QuadraGestalt.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.                 
  7.     DESCRIPTION:
  8.         This file contains a CODE resource to be installed as a Gestalt
  9.         Selector.
  10.  
  11.     NOTES:
  12.         •    Causes your Mac to think its a Quadra. :-)
  13.  
  14.     ___________________________________________________________________________
  15.  
  16.     VERSION HISTORY:
  17.         (Jan 1994, dg)
  18.             •    First publicly distributed version.
  19.  
  20.  
  21.     ___________________________________________________________________________
  22. */
  23. //=============================================================================
  24. //        Include files                                                                     
  25. //-----------------------------------------------------------------------------
  26. #include <GestaltEqu.h>
  27. #include "StandaloneCode.h"
  28. #include "AddrsTable.h"
  29. #include "ESConstants.h"
  30. #include "CodeConstants.h"
  31.  
  32.  
  33.  
  34.  
  35.  
  36. //=============================================================================
  37. //        Global Variables                                                                 
  38. //-----------------------------------------------------------------------------
  39. pascal OSErr    (*gOldGestaltProc) (OSType gestaltSelector, long *gestaltResponse);
  40. Boolean            gAlreadyRan=false;
  41.  
  42.  
  43.  
  44.  
  45.  
  46. //=============================================================================
  47. //        Private function prototypes                             
  48. //-----------------------------------------------------------------------------
  49. pascal OSErr main(OSType gestaltSelector, long *gestaltResponse);
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. //=============================================================================
  61. //        main : Entry point to our code resource.                                                                 
  62. //-----------------------------------------------------------------------------
  63. //        Note :    We call the original Gestalt selector first then fudge the
  64. //                result to be a Quadra. Actually, we don't need to call the
  65. //                original routine, because the information returned isn't
  66. //                used to store other things apart from the machine type. If
  67. //                the result was some sort of bit structure, we would have
  68. //                to get the original result and mask on/off whatever was
  69. //                needed.
  70. //-----------------------------------------------------------------------------
  71. pascal OSErr main(OSType gestaltSelector, long *gestaltResponse)
  72. {    AddressTable    *theAddressTable;
  73.     long            theVal;
  74.     OSErr            theErr;
  75.  
  76.  
  77.  
  78.  
  79.     // Get access to our globals, and save off A4
  80.     PatchGetGlobals();
  81.  
  82.     
  83.     
  84.     // If we've not already been called, call the Gestalt selector to get
  85.     // the address of the old routine. Cast the table entry to a long
  86.     // first so we get what's pointed to by it, rather than a pointer to it.
  87.     if (!gAlreadyRan)
  88.         {
  89.         Gestalt(kMacTypeAddressTable, &theAddressTable);        
  90.         gOldGestaltProc    = (ProcPtr) ((long) theAddressTable->theTable[kMacType]);
  91.         gAlreadyRan        = true;
  92.         }
  93.     
  94.     
  95.     
  96.     // Call the original routine
  97.     theErr = (*gOldGestaltProc)(gestaltSelector, &theVal);
  98.     
  99.     
  100.  
  101.     // Fudge the response to what we want
  102.     *gestaltResponse = gestaltQuadra950;
  103.     theErr = noErr;
  104.     
  105.     
  106.     
  107.     // Restore A4 for our caller and return
  108.     PatchUngetGlobals();
  109.     return(theErr);
  110. }
  111.